Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
No agregando al mapa, manteniendo el mismo nombre "t-1"

Lo estoy haciendo para que si un miembro dice ~nuevo, crea un nuevo boleto para él, pero el problema es que el nombre del canal tiene que ir en un número único, como t-1, luego t-2, etc.

Pero se queda solo con "t-1", para ser claros, estoy usando un controlador de comandos.

aquí está mi código:

 module.exports = { name: 'new', category: 'Ticket', description: 'Creates a new ticket.', aliases: ['newticket'], usage: 'new', userperms: [], botperms: [], run: async (client, message, args) => { let ticketCounter = 1; const userTickets = new Map() if(userTickets.has(message.author.tag)) { return message.channel.send('<@' + message.author.id + '> you already have a ticket, please close your existing ticket first before opening a new one!').then(m => m.delete({timeout: 3000})); } message.guild.channels.create(`t-${ticketCounter}`, { permissionOverwrites: [ { id: message.author.id, allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: "916785912267034674", allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: message.guild.roles.everyone, deny: ['VIEW_CHANNEL'], }, ], type: 'text', }).then(async channel => { channel.setParent('916778691672031293'); userTickets.set(message.author.id, ticketCounter++); message.channel.send(`<@` + message.author.id + `>, you have successfully created a ticket! Please click on ${channel} to view your ticket.`).then(m => m.delete({timeout: 3000})); channel.send(`Hi <@` + message.author.id + `>, welcome to your ticket! Please be patient, we will be with you shortly.`); const logchannel = message.guild.channels.cache.find(channel => channel.name === 'test'); if(logchannel) { logchannel.send(`Ticket-${ticketCounter} created. Click the following to veiw <#${channel.id}>`); } }); } }

¡Gracias!

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Use <Map>.size en lugar de un incrementador ya que el código se vuelve a ejecutar después de cada comando, el contador se establecerá en 1 cada vez.

 if(!client.userTickets) client.userTickets = new Map(); client.userTickets.set(message.author.id, client.userTickets.size + 1); message.guild.channels.create(`t-${client.userTickets.size + 1}`, { ... });

Ejemplo para su código:

 module.exports = { name: 'new', category: 'Ticket', description: 'Creates a new ticket.', aliases: ['newticket'], usage: 'new', userperms: [], botperms: [], run: async (client, message, args) => { if(!client.userTickets) client.userTickets = new Map() if(client.userTickets.has(message.author.id)) { return message.channel.send('<@' + message.author.id + '> you already have a ticket, please close your existing ticket first before opening a new one!').then(m => m.delete({timeout: 3000})); } message.guild.channels.create(`t-${client.userTickets.size + 1}`, { permissionOverwrites: [ { id: message.author.id, allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: "916785912267034674", allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: message.guild.roles.everyone, deny: ['VIEW_CHANNEL'], }, ], type: 'text', }).then(async channel => { channel.setParent('916778691672031293'); client.userTickets.set(message.author.id, client.userTickets.size + 1); message.channel.send(`<@` + message.author.id + `>, you have successfully created a ticket! Please click on ${channel} to view your ticket.`).then(m => m.delete({timeout: 3000})); channel.send(`Hi <@` + message.author.id + `>, welcome to your ticket! Please be patient, we will be with you shortly.`); const logchannel = message.guild.channels.cache.find(channel => channel.name === 'test'); if(logchannel) { logchannel.send(`Ticket-${client.userTickets.size} created. Click the following to veiw <#${channel.id}>`); } }); } }
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda